package com.assjirc.utils;

import java.util.LinkedList;

public class SequentialQueue<E> extends LinkedList<E> {

	private int index;
	private static int MAX_SIZE = 50; // TODO make this a user option

	public E moveBack() {
		
		if (index < this.size() - 1) {
			index++;
		}

		return this.get(index);

	}

	public E moveForward() {
		if (index > 0) {
			index--;
		}

		return this.get(index);
	}

	@Override
	public void push(E e) {
		
		if (this.size() == MAX_SIZE) {
			this.pollLast();
		}
		
		super.push(e);
		index = -1;
	}
}
